"""
MySQL 数据库连接脚本
"""
from tortoise import Tortoise
from config import settings
import asyncio


async def init_db():
    """初始化数据库连接"""
    await Tortoise.init(
        settings.TORTOISE_ORM
    )
    print("数据库连接成功！")


async def close_db():
    """关闭数据库连接"""
    await Tortoise.close_connections()
    print("数据库连接已关闭！")


if __name__ == "__main__":
    asyncio.run(init_db())